# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.Script.V1.Model.ExecutionError do
  @moduledoc """
  An object that provides information about the nature of an error resulting from an attempted execution of a script function using the Apps Script API. If a run call succeeds but the script function (or Apps Script itself) throws an exception, the response body's error field contains a Status object. The `Status` object's `details` field contains an array with a single one of these `ExecutionError` objects.

  ## Attributes

  *   `errorMessage` (*type:* `String.t`, *default:* `nil`) - The error message thrown by Apps Script, usually localized into the user's language.
  *   `errorType` (*type:* `String.t`, *default:* `nil`) - The error type, for example `TypeError` or `ReferenceError`. If the error type is unavailable, this field is not included.
  *   `scriptStackTraceElements` (*type:* `list(GoogleApi.Script.V1.Model.ScriptStackTraceElement.t)`, *default:* `nil`) - An array of objects that provide a stack trace through the script to show where the execution failed, with the deepest call first.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :errorMessage => String.t() | nil,
          :errorType => String.t() | nil,
          :scriptStackTraceElements =>
            list(GoogleApi.Script.V1.Model.ScriptStackTraceElement.t()) | nil
        }

  field(:errorMessage)
  field(:errorType)

  field(:scriptStackTraceElements,
    as: GoogleApi.Script.V1.Model.ScriptStackTraceElement,
    type: :list
  )
end

defimpl Poison.Decoder, for: GoogleApi.Script.V1.Model.ExecutionError do
  def decode(value, options) do
    GoogleApi.Script.V1.Model.ExecutionError.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.Script.V1.Model.ExecutionError do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
